package com.ithanwen.controller;

import com.ithanwen.pojo.Emp;
import com.ithanwen.pojo.LoginInfo;
import com.ithanwen.pojo.Result;
import com.ithanwen.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created By tony
 * <br/>Date: 2025/8/12 20:35
 * <br/>Description:
 */
@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public Result login(@RequestBody Emp emp){
        LoginInfo loginInfo = loginService.login(emp.getUsername(), emp.getPassword());
        return loginInfo != null ? Result.success(loginInfo) : Result.error("用户名或密码错误");
    }
}
